﻿
@{
    ViewBag.Title = "图纸组合";
    Layout = "~/Views/Shared/_MyLayoutPage.cshtml";
}

@section head{
    <link rel="stylesheet" href="~/Content/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css" />
    <link rel="stylesheet" href="~/Content/zTree_v3/css/demo.css" type="text/css" />
    <script type="text/javascript" src="~/Content/zTree_v3/js/jquery.ztree.all.js"></script>

    <style>
        html, body {
            height: 100%;
            width: 100%;
        }

        .parent {
            display: flex;
            height: 100%;
            width: 100%;
        }

        .left {
            width: 400px;
            height: 100%;
            background-color: white;
        }

        .right {
            display: flex;
            flex: 1;
            height: 100%;
            background-color: whitesmoke;
        }

        .ztree li span.button.add {
            margin-left: 2px;
            margin-right: -1px;
            background-position: -144px 0;
            vertical-align: top;
            *vertical-align: middle
        }
    </style>
}

<div class="parent">
    <div class="left">
        <div>
            <ul id="treeDemo" class="ztree" style="width:100%;height:100%;"></ul>
        </div>
    </div>
    <div class="right">
        <div>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>图号领取明细</legend>
            </fieldset>
            <form class="layui-form" enctype="multipart/form-data">
                <div class="layui-form-item">
                    <label class="layui-form-label">搜索</label>
                    <div class="layui-input-block">
                        <input type="text" id="SearchText" name="Title1" required lay-verify="required" onkeypress="getKey()" placeholder="输入图纸号" class="layui-input" style="width:300px;float:left;">
                        <input type="text" value="" style="display:none" />
                        <button type="button" class="layui-btn layui-btn-normal" style="float:left;" onclick="SearchFunc()"><i class="layui-icon">&#xe615;</i></button>
                        <button type="button" class="layui-btn layui-btn-normal" style="float:left;" id="BtnGetDraw"><i class="layui-icon">&#xe621;</i>添加组件</button>
                    </div>
                </div>
            </form>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>图纸领取</legend>
            </fieldset>
            <div>

                <blockquote class="layui-elem-quote" style="text-align: center;">
                    选中的节点信息：<span id="SelNodeInfo"></span>
                </blockquote>


            </div>

            <table id="DrawComboTable" lay-filter="DrawComboTableList"></table>
        </div>
    </div>
</div>

@*添加新组合时，添加根节点选择框*@
<div id="GetDrawLayer" style="display:none;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>图号选择</legend>
    </fieldset>

    <form class="layui-form" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">搜索</label>
            <div class="layui-input-block">
                <input type="text" id="DrawSelSearchText" name="Title1" required lay-verify="required" onkeypress="DrawSelGetKey()" placeholder="输入图纸号" class="layui-input" style="width:300px;float:left;">
                <input type="text" value="" style="display:none" />
                <button type="button" class="layui-btn layui-btn-normal" style="float:left;" onclick="DrawSelSearchFunc()"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </div>
    </form>

    <table id="GetDrawTable" lay-filter="GetDrawTableList"></table>
</div>


@*添加子节点，从图纸上选择*@
<div id="AddNodeByDrawLayer" style="display:none;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>从零部件选择</legend>
    </fieldset>

    <form class="layui-form" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">搜索</label>
            <div class="layui-input-block">
                <input type="text" id="AddNodeByDrawSearchText" name="Title1" required lay-verify="required" onkeypress="AddNodeByDrawGetKey()" placeholder="输入图纸号" class="layui-input" style="width:300px;float:left;">
                <input type="text" value="" style="display:none" />
                <button type="button" class="layui-btn layui-btn-normal" style="float:left;" onclick="AddNodeByDrawSearchFunc()"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </div>
    </form>

    <table id="AddNodeByDrawTable" lay-filter="AddNodeByDrawTableList"></table>
</div>

@*添加子节点，从组合上选择*@
<div id="AddNodeByComboLayer" style="display:none;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>从组件添加</legend>
    </fieldset>

    <form class="layui-form" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">搜索</label>
            <div class="layui-input-block">
                <input type="text" id="AddNodeByComboSearchText" name="Title1" required lay-verify="required" onkeypress="AddNodeByComboGetKey()" placeholder="输入图纸号" class="layui-input" style="width:300px;float:left;">
                <input type="text" value="" style="display:none" />
                <button type="button" class="layui-btn layui-btn-normal" style="float:left;" onclick="AddNodeByComboSearchFunc()"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </div>
    </form>

    <table id="AddNodeByComboTable" lay-filter="AddNodeByComboTableList"></table>
</div>



<script type="text/javascript">

    var TCurr_Id = "";
    var TCurr_IncreaseNum = "";
    var TCurr_MotorId = "";
    var TCurr_SerialDrawName = "";
    var TCurr_SerialDrawNum = "";
    var TCurr_ComboId = "";


    var setting = {
        view: {
            expandSpeed: "",
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom,
            selectedMulti: false
        },
        edit: {
            enable: true,
            showRemoveBtn: true,
            showRenameBtn: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onClick: zTreeOnClick,
            beforeRemove: zTreeBeforeRemove,
        }
    };

    function LoadTreeCombo(ComboId) {

        DataObj = {};
        DataObj["ComboId"] = ComboId;
        $.ajax({
            type: "POST",
            url: "/Api/LoadTree_DrawCombo",
            async: false,
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(DataObj),
            success: function (msg) {
                if (msg.result == "OK") {
                    var zTreeObj = $.fn.zTree.getZTreeObj("treeDemo");
                    if (zTreeObj != null) {
                        zTreeObj.destroy();
                    }
                    var TreeJsonStr = msg.TreeObjStr;
                    TreeJson = JSON.parse(TreeJsonStr);
                    $.fn.zTree.init($("#treeDemo"), setting, TreeJson);
                    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                    treeObj.expandAll(true);

                } else {
                    alert(msg.result);
                }
            }
        });
    }


    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0) return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
            + "' title='add node' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.tId);

        //新增节点
        if (btn) btn.bind("click", function () {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            TCurr_Id = treeNode.Id;
            TCurr_IncreaseNum = treeNode.IncreaseNum;
            TCurr_MotorId = treeNode.MotorId;
            TCurr_SerialDrawName = treeNode.SerialDrawName;
            TCurr_SerialDrawNum = treeNode.SerialDrawNum;
            TCurr_ComboId = treeNode.ComboId;
            str = "名称：" + TCurr_SerialDrawName + "、图纸编号：" + TCurr_SerialDrawNum + "." + TCurr_IncreaseNum + "、电机型号：" + TCurr_MotorId;


            var data = {};
            data["NodeName"] = "新增节点";
            //data["DrawNum"] = 0;
            data["IsParent"] = 0;
            data["ParentId"] = treeNode.Id;


            index = layer.confirm(str, {
                btn: ['添加零部件', '添加组件', '取消'] //可以无限个按钮
                , btn1: function (index) {
                    //打开图纸选择层
                    layer.close(index);
                    index = layer.open({
                        type: 1,
                        title: ['新增', 'font-size:18px;'],
                        area: ['1000px', '800px'],
                        offset: 'rt',
                        shade: 0.5,
                        content: $("#AddNodeByDrawLayer")
                    });
                    table.reload("AddNodeByDrawTable", {
                        where: {
                            SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0  and Type='零部件' and not (a.motorId='" + TCurr_MotorId + "' and a.SerialDrawNum='" + TCurr_SerialDrawNum + "' and a.IncreaseNum='" + TCurr_IncreaseNum+"')"
                        },
                        page: {
                            curr: 1
                        }
                    });
                }
                , btn2: function (index) {
                    //打组合选择层
                    layer.close(index);
                    index = layer.open({
                        type: 1,
                        title: ['新增', 'font-size:18px;'],
                        area: ['1000px', '800px'],
                        offset: 'rt',
                        shade: 0.5,
                        content: $("#AddNodeByComboLayer")
                    });
                    table.reload("AddNodeByComboTable", {
                        where: {
                            SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0 and ParentId=0 and  not (a.motorId='" + TCurr_MotorId + "' and a.SerialDrawNum='" + TCurr_SerialDrawNum + "' and a.IncreaseNum='" + TCurr_IncreaseNum + "')"
                        },
                        page: {
                            curr: 1
                        }
                    });

                }
                , btn3: function (index) {
                    alert(3);
                    layer.close(index);
                }
            });


            return false;
        });
    };
    function removeHoverDom(treeId, treeNode) {

        $("#addBtn_" + treeNode.tId).unbind().remove();
    };

    function zTreeOnClick(event, treeId, treeNode) {

        var data = {};
        data["Id"] = treeNode.Id;
        TreeNodeId = treeNode.Id;

        var str = ""
        TCurr_Id = treeNode.Id;
        TCurr_IncreaseNum = treeNode.IncreaseNum;
        TCurr_MotorId = treeNode.MotorId;
        TCurr_SerialDrawName = treeNode.SerialDrawName;
        TCurr_SerialDrawNum = treeNode.SerialDrawNum;
        str = "名称：" + TCurr_SerialDrawName + "、图纸编号：" + TCurr_SerialDrawNum + "." + TCurr_IncreaseNum + "、电机型号：" + TCurr_MotorId;
        $("#SelNodeInfo").text(str);


    };


    function zTreeBeforeRemove(treeId, treeNode) {
        layer.confirm('<span class="layui-icon"></span>' + '是否真的要删除该节点？', {
            btn: ['确定', '取消'] //可以无限个按钮
            , btn1: function (index) {

                DataObj = {};
                DataObj["Id"] = treeNode.Id;
                $.ajax({
                    type: "POST",
                    url: "/Api/DelDrawCombo",
                    async: false,
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(DataObj),
                    success: function (msg) {
                        if (msg.result == "OK") {
                            layer.close(index);
                            layer.closeAll();
                            layer.msg('删除成功', { icon: 6, time: 1000 });
                            table.reload("DrawComboTable", {
                                where: {
                                    SortName: "a.id", Order: "Desc", Condition: " and a.IsDelete=0 and ParentId=0"
                                },
                                page: {
                                    curr: 1
                                }
                            });
                            LoadTreeCombo(treeNode.ComboId);

                        } else {
                            alert(msg.result);

                        }
                    }
                });
                //layer.close(index);
            }
            , btn2: function (index) {
                //按钮【按钮三】的回调
                //alert("2");
            }
        });

        return false;
    }


    var layer;
    var index;
    var DrawSelTable;
    layui.use(['form', 'table', 'upload', 'layer'], function () {
        var form = layui.form;
        var tab = parent.tab;
        var form = layui.form;
        table = layui.table;
        layer = layui.layer;

        //新增用户保存
        $("#BtnGetDraw").on("click", function () {
            index = layer.open({
                type: 1,
                title: ['新增', 'font-size:18px;'],
                area: ['1000px', '800px'],
                offset: 'rt',
                shade: 0,
                content: $("#GetDrawLayer")
            });
        });



        table.render({
            elem: '#GetDrawTable'
            , method: 'post'
            //, height: 315
            , url: '/api/GetDrawTableRequest' //数据接口
            , page: true //开启分页
            , where: { SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0 and a.Type='组件'" }
            , limits: [10, 50, 100]

            , cols: [[ //表头
                { field: 'SerialDrawName', title: '序列名称', width: 200 },
                { field: 'MotorId', title: '电机型号', width: 200 },
                { field: 'SerialDrawNum', title: '序列编号', width: 120 },
                { field: 'IncreaseNum', title: '自增编号', width: 120 },
                , {
                    field: "operation", title: "操作", width: 150, fixed: "right",
                    templet: function (d) {
                        return '' +
                            '<a class="layui-btn layui-btn-xs" lay-event="AddRoot">选择根节点</a>';
                    }
                }
            ]]
        });


        table.on("tool(GetDrawTableList)", function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if (layEvent == 'AddRoot') {
                layer.confirm('<span class="layui-icon"></span>' + '是否真的要新增根节点？', {
                    btn: ['确定', '取消'] //可以无限个按钮
                    , btn1: function (index) {

                        DataObj = {};
                        DataObj["DrawDetailId"] = data.Id;
                        DataObj["SerialDrawName"] = data.SerialDrawName;
                        DataObj["SerialDrawNum"] = data.SerialDrawNum;
                        DataObj["IncreaseNum"] = data.IncreaseNum;
                        DataObj["MotorId"] = data.MotorId;
                        DataObj["ParentId"] = 0;
                        DataObj["IsDelete"] = 0;
                        DataObj["InstallNum"] = 0;
                        DataObj["Memo"] = data.Memo;

                        $.ajax({
                            type: "POST",
                            url: "/Api/AddRootDrawCombo",
                            async: false,
                            contentType: "application/json",
                            dataType: "json",
                            data: JSON.stringify(DataObj),
                            success: function (msg) {
                                if (msg.result == "OK") {
                                    layer.msg('添加成功', { icon: 6, time: 1000 });
                                    layer.close(index);
                                    layer.closeAll();
                                    table.reload("DrawComboTable", {
                                        where: {
                                            SortName: "a.id", Order: "Desc", Condition: " and a.IsDelete=0 and ParentId=0"
                                        },
                                        page: {
                                            curr: 1
                                        }
                                    });
                                } else {
                                    alert(msg.result);
                                }
                            }
                        });
                        //layer.close(index);
                    }
                    , btn2: function (index) {
                        //按钮【按钮三】的回调
                        //alert("2");
                    }
                });
            }
        });



        ////////////////////////////////////////////////
        //已经生成好了的组合 展示t_d_DrawCombo表的根节点
        table.render({
            elem: '#DrawComboTable'
            , method: 'post'
            //, height: 315
            , url: '/api/DrawComboTableRequest' //数据接口
            , page: true //开启分页
            , where: { SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0 and ParentId=0" }
            , limits: [10, 50, 100]
            , cols: [[ //表头
                { field: 'SerialDrawName', title: '序列名称', width: 200 },
                { field: 'MotorId', title: '电机型号', width: 200 },
                { field: 'SerialDrawNum', title: '序列编号', width: 120 },
                { field: 'IncreaseNum', title: '自增编号', width: 120 },
                , {
                    field: "operation", title: "操作", width: 150, fixed: "right",
                    templet: function (d) {
                        return '' +
                            '<a class="layui-btn layui-btn-xs" lay-event="ShowDetail">显示详情</a>';
                    }
                }
            ]]
        });



        table.on("tool(DrawComboTableList)", function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if (layEvent == 'ShowDetail') {


                TCurr_Id = "";
                TCurr_IncreaseNum = "";
                TCurr_MotorId = "";
                TCurr_SerialDrawName = "";
                TCurr_SerialDrawNum = "";
                $("#SelNodeInfo").text("");
                DataObj = {};
                DataObj["ComboId"] = data.ComboId;


                $.ajax({
                    type: "POST",
                    url: "/Api/LoadTree_DrawCombo",
                    async: false,
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(DataObj),
                    success: function (msg) {
                        if (msg.result == "OK") {
                            var zTreeObj = $.fn.zTree.getZTreeObj("treeDemo");
                            if (zTreeObj != null) {
                                zTreeObj.destroy();
                            }


                            var TreeJsonStr = msg.TreeObjStr;
                            TreeJson = JSON.parse(TreeJsonStr);
                            $.fn.zTree.init($("#treeDemo"), setting, TreeJson);
                            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                            treeObj.expandAll(true);

                        } else {
                            alert(msg.result);
                        }
                    }
                });
            }
        });

        //////////////////////////////////////////////////////////////////////////
        ////////从零部件 增加子节点操作
        table.render({
            elem: '#AddNodeByDrawTable'
            , method: 'post'
            //, height: 315
            , url: '/api/GetDrawTableRequest' //数据接口
            , page: true //开启分页
            , where: { SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0 and Type='零部件'" }
            , limits: [10, 50, 100]

            , cols: [[ //表头
                { field: 'SerialDrawName', title: '序列名称', width: 200 },
                { field: 'SerialDrawNum', title: '序列编号', width: 120 },
                { field: 'MotorId', title: '电机型号', width: 200 },
                { field: 'IncreaseNum', title: '自增编号', width: 120 },
                , {
                    field: "operation", title: "操作", width: 150, fixed: "right",
                    templet: function (d) {
                        return '' +
                            '<a class="layui-btn layui-btn-xs" lay-event="AddNode">添加</a>';
                    }
                }
            ]]
        });

        table.on("tool(AddNodeByDrawTableList)", function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if (layEvent == 'AddNode') {

                DataObj = {};
                DataObj["ParentId"] = TCurr_Id;
                DataObj["SerialDrawName"] = data.SerialDrawName;
                DataObj["SerialDrawNum"] = data.SerialDrawNum;
                DataObj["IncreaseNum"] = data.IncreaseNum;
                DataObj["MotorId"] = data.MotorId;
                DataObj["ComboId"] = TCurr_ComboId;
                DataObj["DrawDetailId"] = data.Id;

                $.ajax({
                    type: "POST",
                    url: "/Api/AddDrawComboByDraw",
                    async: false,
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(DataObj),
                    success: function (msg) {
                        if (msg.result == "OK") {
                            var zTreeObj = $.fn.zTree.getZTreeObj("treeDemo");
                            if (zTreeObj != null) {
                                zTreeObj.destroy();
                            }


                            var TreeJsonStr = msg.TreeObjStr;
                            TreeJson = JSON.parse(TreeJsonStr);
                            $.fn.zTree.init($("#treeDemo"), setting, TreeJson);
                            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                            treeObj.expandAll(true);
                            layer.closeAll();

                        } else {
                            alert(msg.result);
                        }
                    }
                });
            }
        });

        //////////////////////////////////////////////////////////////////////////
        ////////从组合 增加子节点操作
        table.render({
            elem: '#AddNodeByComboTable'
            , method: 'post'
            //, height: 315
            , url: '/api/DrawComboTableRequest' //数据接口
            , page: true //开启分页
            , where: { SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0 and ParentId=0" }
            , limits: [10, 50, 100]
            , cols: [[ //表头
                { field: 'SerialDrawName', title: '序列名称', width: 200 },
                { field: 'MotorId', title: '电机型号', width: 200 },
                { field: 'SerialDrawNum', title: '序列编号', width: 120 },
                { field: 'IncreaseNum', title: '自增编号', width: 120 },
                , {
                    field: "operation", title: "操作", width: 150, fixed: "right",
                    templet: function (d) {
                        return '' +
                            '<a class="layui-btn layui-btn-xs" lay-event="AddNode">添加</a>';
                    }
                }
            ]]
        });


        table.on("tool(AddNodeByComboTableList)", function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if (layEvent == 'AddNode') {

                DataObj = {};
                DataObj["ParentId"] = TCurr_Id;     //  需要挂接的父节点Id
                DataObj["ParentComboId"] = TCurr_ComboId;   //当前挂接的父节点Id
                DataObj["ComboId"] = data.ComboId;  //  当前组合的ComboId
                DataObj["ComboRootId"] = data.Id;   //  当前组合的根节点Id

                $.ajax({
                    type: "POST",
                    url: "/Api/AddNodeByCombo",
                    async: false,
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(DataObj),
                    success: function (msg) {
                        if (msg.result == "OK") {
                            var zTreeObj = $.fn.zTree.getZTreeObj("treeDemo");
                            if (zTreeObj != null) {
                                zTreeObj.destroy();
                            }


                            var TreeJsonStr = msg.TreeObjStr;
                            TreeJson = JSON.parse(TreeJsonStr);
                            $.fn.zTree.init($("#treeDemo"), setting, TreeJson);
                            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                            treeObj.expandAll(true);
                            layer.closeAll();

                        } else {
                            alert(msg.result);
                        }
                    }
                });
            }
        });

    });


    //回车键
    function getKey() {
        if (event.keyCode == 13) {
            SearchFunc();
        }
    }

    function SearchFunc() {
        var text = $("#SearchText").val();
        if (text == "") {
            table.reload("DrawComboTable", {
                where: {
                    SortName: "a.id", Order: "Desc", Condition: " and a.IsDelete=0 and ParentId=0"
                },
                page: {
                    curr: 1
                }
            });
        }
        else {
            table.reload("DrawComboTable", {
                where: {
                    SortName: "a.id", Order: "Desc", Condition: " and a.IsDelete=0 and ParentId=0 and (MotorId like '%" + text + "%')"
                },
                page: {
                    curr: 1
                }
            });
        }
    }



    //从图纸选择 搜索模块
    function AddNodeByDrawGetKey() {
        if (event.keyCode == 13) {
            AddNodeByDrawSearchFunc();
        }
    }

    function AddNodeByDrawSearchFunc() {
        var text = $("#AddNodeByDrawSearchText").val();
        if (text == "") {
            table.reload("AddNodeByDrawTable", {
                where: {
                    SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0"
                },
                page: {
                    curr: 1
                }
            });
        }
        else {
            table.reload("AddNodeByDrawTable", {
                where: {
                    SortName: "a.id", Order: "Desc", Condition: " and a.IsDelete=0 and not (a.motorId='" + TCurr_MotorId + "' and a.SerialDrawNum='" + TCurr_SerialDrawNum + "' and a.IncreaseNum='" + TCurr_IncreaseNum + "') and  MotorId like '%" + text + "%')"
                },
                page: {
                    curr: 1
                }
            });
        }
    }


    //从图纸选择 搜索模块
    function AddNodeByComboGetKey() {
        if (event.keyCode == 13) {
            AddNodeByComboSearchFunc();
        }
    }

    function AddNodeByComboSearchFunc() {
        var text = $("#AddNodeByComboSearchText").val();
        if (text == "") {
            table.reload("AddNodeByComboTable", {
                where: {
                    SortName: "a.id", Order: "desc", Condition: "and a.IsDelete=0 and ParentId=0"
                },
                page: {
                    curr: 1
                }
            });
        }
        else {
            table.reload("AddNodeByComboTable", {
                where: {
                    SortName: "a.id", Order: "Desc", Condition: "and a.IsDelete=0 and ParentId=0 and  not (a.motorId='" + TCurr_MotorId + "' and a.SerialDrawNum='" + TCurr_SerialDrawNum + "' and a.IncreaseNum='" + TCurr_IncreaseNum + "') and  MotorId like '%" + text + "%'"
                },
                page: {
                    curr: 1
                }
            });
        }
    }


</script>




































